package com.bsoft.gol.editor.service.impl;


import com.bsoft.gol.editor.dao.ImportLogDAO;
import com.bsoft.gol.editor.editor.ImportLog;
import com.bsoft.gol.editor.service.ImportLogService;
import ctd.spring.boot.annotation.SsdevService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.List;

@SsdevService("importLogService")
public class ImportLogServiceImpl implements ImportLogService {

	@Autowired
    private ImportLogDAO importLogDAO;

	@Override
    public ImportLog saveImportLog(ImportLog log){
		log.setCreatedDate(new Date());
//		log.setCreatedBy(RpcUserToken.getUserId());
		log.setDownload(0);
		return importLogDAO.save(log);
	}

	@Override
    public void updateImportLogDownloadInfo(ImportLog log) throws InterruptedException{
		importLogDAO.updateDownloadInfo(log.getId(),log.getDownloadDate());
	}

	@Override
    public List<ImportLog> queryLogNotDownloadByDataType(String dataType){
		return importLogDAO.queryDownLoadLogByDataType(dataType);
	}

	@Override
    public ImportLog getLogById(int id){
		return importLogDAO.get(id);
	}

	public void setImportLogDAO(ImportLogDAO importLogDAO) {
		this.importLogDAO = importLogDAO;
	}
}
